package reflect;

import java.io.FileNotFoundException;
import java.io.FileReader;

public class AboutPath {
    public static void main(String[] args) throws FileNotFoundException {
       // 传统方法--移植性较差
       FileReader reader = new FileReader("src/reflect/classinfo.properties");

       //通用方法：获得绝对路径
        // 前提是文件必须在类路径之下
        //类路径：src文件下
        String path= Thread.currentThread().getContextClassLoader().getResource("classinfo2.properties").getPath();
        System.out.println(path);

        //获取reflect里的classinfo文件
        String inpath = Thread.currentThread().getContextClassLoader()
                .getResource("reflect/classinfo.properties").getPath();
        System.out.println(inpath);
    }
}
